package recycle.controller;

import recycle.pojo.Recycleemployeerecord;
import recycle.service.RecycleemployeerecordService;
import recycle.utils.Page;
import recycle.vo.RecycleemployeerecordParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 描述：回收人员分配记录表 控制器
* @author 赵韧
* @date 2019/07/22
*/
@RestController
@RequestMapping("/recycleemployeerecord")
public class RecycleemployeerecordController{
	@Resource
	private RecycleemployeerecordService recycleemployeerecordService;
 	
 	@RequestMapping("/findById.json")
    public Recycleemployeerecord findById(Integer recordId){
        Recycleemployeerecord result = null;
        try {
            result = recycleemployeerecordService.findById(recordId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：获取所有的Recycleemployeerecord对象
     */
    @RequestMapping("/findAll.json")
    public List<Recycleemployeerecord> findAll(){
        List<Recycleemployeerecord> result = null;
        try {
            result = recycleemployeerecordService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：新增保存Recycleemployeerecord对象
     */
    @RequestMapping("/save.json")
    public Map save(Recycleemployeerecord recycleemployeerecord){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存回收人员分配记录表失败");
        try {
            if(recycleemployeerecordService.save(recycleemployeerecord)>0){
                result.put("flag",true);
                result.put("msg","保存回收人员分配记录表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：根据主键删除回收人员分配记录表对象
     * @param recordId
     */
    @RequestMapping("/delete.json")
    public Map delete(Integer recordId){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存回收人员分配记录表失败");
        try {
            if(recycleemployeerecordService.delete(recordId)>0){
                result.put("flag",true);
                result.put("msg","保存回收人员分配记录表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：更新回收人员分配记录表对象
     */
    @RequestMapping("/update.json")
    public Map update(Recycleemployeerecord recycleemployeerecord){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","更新回收人员分配记录表失败");
        try {
            if( recycleemployeerecordService.update(recycleemployeerecord)>0){
                result.put("flag",true);
                result.put("msg","更新回收人员分配记录表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;

    }

    /**
     * 根据不确定的条件，动态查询
     */
    @RequestMapping("/query.json")
    public List<Recycleemployeerecord> query(RecycleemployeerecordParam param){
        List<Recycleemployeerecord> result = null;
        try {
            result = recycleemployeerecordService.query(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    @RequestMapping("/queryByPage.json")
    public Page queryByPage(RecycleemployeerecordParam param){
        Page result = null;
        try {
            result = recycleemployeerecordService.queryByPage(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    @RequestMapping("/findAllEmployee.json")
   public List<Recycleemployeerecord> findAllEmployee(){
        List<Recycleemployeerecord> list =recycleemployeerecordService.findAllEmployee();
       /* for (int i = 0; i <list.size() ; i++) {
            Recycleemployeerecord rc=list.get(i);
            if(rc.getEmployeeId()==1){
                rc.setOther1("张三");
            }
            if(rc.getEmployeeId()==2){
                rc.setOther1("李四");
            }
            if(rc.getEmployeeId()==3){
                rc.setOther1("王五");
            }
            if(rc.getEmployeeId()==4){
                rc.setOther1("赵六");
            }
        }*/
        return list;
    }

}
